package erfgame.core.world.generator.terrain;

import java.util.ArrayList;
import java.util.List;

import erfgame.core.world.World;
import erfgame.core.world.WorldUpdateDescription;
import erfgame.core.world.WorldUpdater;

public class CompositeWorldUpdater implements WorldUpdater {
	
	private ArrayList<WorldUpdater> worldGenerators;
	
	public CompositeWorldUpdater() {
		this.worldGenerators = new ArrayList<WorldUpdater>();
	}
	
	public void addWorldGenerator( WorldUpdater worldGenerator ) {
		this.worldGenerators.add( worldGenerator );
	}
	
	public List<WorldUpdateDescription> update(World world, long ticks) {
		ArrayList<WorldUpdateDescription> result = new ArrayList<WorldUpdateDescription>();
		for( WorldUpdater worldGenerator : this.worldGenerators ) {
			System.out.println( worldGenerator.getClass().getName()+"..." );
			List<WorldUpdateDescription> childResult;
			childResult = worldGenerator.update( world, ticks );
			// TODO : merge/discard where appropriate
			result.addAll( childResult );
		}
		return result;
	}
}
